package cn.fx.framework.web;

import cn.fx.framework.redis.MyRedisCacheManager;
import cn.fx.framework.redis.MyRedisTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

/**
 * 默认实现，每个项目各自实现
 * @author ljh
 * @date 2018-08-23 14:03
 */
public abstract class AbstractApplicationHandler implements ApplicationHandler {

    private static final Logger log = LoggerFactory.getLogger(AbstractApplicationHandler.class);

    private MyRedisCacheManager redisCacheManager;
    private MyRedisTemplate redisTemplate;
    private ApplicationContext applicationContext;

    public AbstractApplicationHandler(ApplicationContext applicationContext){
        this.applicationContext = applicationContext;
    }

    public AbstractApplicationHandler(String activeString,String redisKeyPrefix){
    }
    @Override
    public ApplicationContext getApplicationContext() {
        return this.applicationContext;
    }


    @Override
    public void setRedisCacheMananger(MyRedisCacheManager redisCacheManager){
        this.redisCacheManager = redisCacheManager;
        //字典启用本地缓存
        MyRedisCacheManager.ENABLE_LOCAL_CACHE_SET.add("dict");
        MyRedisCacheManager.ENABLE_LOCAL_CACHE_SET.add("user");
        MyRedisCacheManager.ENABLE_LOCAL_CACHE_SET.add("org");
    }

    @Override
    public void setMyRedisTemplate(MyRedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    @Override
    public String getName() {
        return "starter";
    }

    @Override
    public String getVersion() {
        return "v201809.1";
    }



}
